<template>
	<view class="orderlist">
		<view class="list" v-for="(item,index) in OrderList" :key="index">
			<view class="top">
				<text class="top_left">挂售编号：{{item.order_number}}</text>
				<text class="top_right">{{item.ctext}}</text>
				<text class="top_right">{{item.staName}}</text>
			</view>
			<view class="cont">
				<view class="text">
					<text class="title">挂售时间</text>
					<text class="number time">{{item.create_time}}</text>
				</view>
				<view class="text">
					<text class="title">挂售额度</text>
					<text class="number">{{item.money}}</text>
				</view>
			</view>
		</view> 
		<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		data() {
			return {
				OrderList: [],
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				page: 1,
				loadmore: false, //是否加载
			};
		},
		components: {
			uniLoadMore
		},
		onLoad() {
			this.getData(this.page)
		},
		methods: {
			getData: function(page) {
				const _this = this;
				const data = {
					page: page
				}
				this.$request.post("/api/ucenter/getSellList", {
						data: data
					})
					.then(res => {
						if (res.data.code == 1) {
							//循环遍历,将新数组追加到list数组中  
							for (let i = 0; i < res.data.data.list.length; i++) {
								_this.OrderList.push(res.data.data.list[i])
							}
							//如果数组长度不够10条就停止加载
							if (res.data.data.list.length < 10) {
								_this.loadmore = true;
							}
						}
					})
					.catch(error => {
						console.error('error:', error);
					});
			},
			
		},
		onReachBottom() { //上啦加载函数
			let _this = this;
			if (this.loadingType !== 0) {
				return;
			}
			this.page++;
			this.loadingType = 1;
			this.getData(this.page)
			setTimeout(() => {
				//如果数据已经加载完就停止加载.
				if (_this.loadmore) {
					this.loadingType = 2;
					return;
				}
				this.loadingType = 0;
			}, 2000);
		},
	}
</script>

<style lang="less">
	.orderlist {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;

		.list {
			width: 96%;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.19);
			border-radius: 8px;
			margin: 10px auto;
			display: flex;
			flex-direction: column;
			overflow: hidden;
			font-size: 14px;

			.top {
				background: #1D7BFF;
				color: #fff;
				height: 30px;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 10px;
			}

			.cont {
				display: flex;
				padding: 10px 0;

				.text {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;

					.title {
						font-weight: 700;
					}

					.number {
						line-height: 30px;
					}

					.time {
						
						text-align: center;
						font-size: 14px;
					}
				}
			}

			.buttom {
				margin: auto 10px;
				border-top: 1px solid #eee;
				font-size: 12px;
				display: flex;
				line-height: 20px;
				justify-content: space-between;
				padding: 10px 0;
				.lock {
					border:1px solid #1D7BFF;
					padding: 0 10px;
				}
			}
		}
	}
</style>
